home *** CD-ROM | disk | FTP | other *** search
- package horst;
-
- import java.net.URL;
- import java.util.Vector;
-
- public class HistoryManager {
- Vector m_urls = new Vector();
- int m_ptr = -1;
-
- public void add(URL u) {
- if (this.m_ptr == this.m_urls.size() - 1) {
- this.m_urls.addElement(u);
- this.m_ptr = this.m_urls.size() - 1;
- } else {
- ++this.m_ptr;
- this.m_urls.insertElementAt(u, this.m_ptr);
-
- for(int i = this.m_urls.size() - 1; i > this.m_ptr; --i) {
- this.m_urls.removeElementAt(i);
- }
- }
-
- }
-
- public URL back() {
- if (this.m_ptr > 0 && this.m_ptr - 1 < this.m_urls.size()) {
- --this.m_ptr;
- return (URL)this.m_urls.elementAt(this.m_ptr);
- } else {
- return null;
- }
- }
-
- public boolean canMoveBack() {
- return this.m_ptr > 0;
- }
-
- public boolean canMoveForward() {
- return this.m_ptr + 1 < this.m_urls.size();
- }
-
- public void clear() {
- this.m_urls.removeAllElements();
- }
-
- public URL forward() {
- if (this.m_ptr + 1 < this.m_urls.size()) {
- ++this.m_ptr;
- return (URL)this.m_urls.elementAt(this.m_ptr);
- } else {
- return null;
- }
- }
- }
-